package com.kzf.mapper;

import com.kzf.pojo.Student;
import com.kzf.pojo.StudentDTO;
import com.kzf.pojo.StudentQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {
    List<Student> getStudent(StudentQueryParam studentQueryParam);


    void deleteByIds(List<Integer> idList);

    @Insert("insert into student(name, no, gender, phone, id_card, is_college, address, degree, graduation_date, clazz_id, violation_count, violation_score, create_time, update_time) values " +
            "(#{name},#{no},#{gender},#{phone},#{idCard},#{isCollege},#{address},#{degree},#{graduationDate},#{clazzId},#{violationCount},#{violationScore},#{createTime},#{updateTime})")
    void addStudent(Student student);

    @Select("select * from student where id = #{id}")
    StudentDTO getStudentById(Integer id);

    void updateStudent(Student student);

    @Update("update student set violation_score = #{score} where id =#{id}")
    void updateScore(Integer id, Integer score);

    @MapKey("degree")
    List<Map<String, Object>> getStudentDegreeData();

    @MapKey("className")
    List<Map<String, Object>> getStudentCountData();
}
